import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import "./assets/css/common.css"
// Vue.config.productionTip = false;
Vue.use(ElementUI);

// 路由守卫
// console.log(router)
router.beforeEach((to,from,next)=>{
  // console.log('to',to)
  // console.log('from',from)
  // console.log('next',next)
  // next()

  let token=localStorage.getItem('qf-token')
  if(token){
    next()
  }else{
    // 用户没有登入，不能访问登入页面以外的页面

    // 如果登入的页面是login,就放行，通过to判断

    if(to.path==="/login"){
      next()
    }else{
      next({path:"/login"})
    }

  }
})


new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
